﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using ScriptEditor;
using Main.Engine;
using Main.UI;
using WeifenLuo.WinFormsUI.Docking;
using Main.UI.Components;
using Main.Common;

namespace Main
{
    public partial class Console : Form, IStudio
    {
        internal static Console Instance { get; private set;}
        
        public Console()
        {
            Instance = this;
            InitializeComponent();
        }

        public DockPanel MainDock { get { return this.MainDockPanel; } }
        public Ribbon MainRibbonBar { get { return this.RibbonBar; } }

        private void Console_Load(object sender, EventArgs e)
        {
            foreach (var win in ServiceLocator.Instance.Locate<IWindowManager>().ToolWindows)
                win.Adjust(Visibility.Show);
            Services.ServiceLocator = ServiceLocator.Instance;
        }

        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            //SourceEditor doc = new SourceEditor();
            //SetScintillaToCurrentOptions(doc);
            //doc.Text = String.Format(CultureInfo.CurrentCulture, "{0}{1}", NEW_DOCUMENT_TEXT, ++_newDocumentCount);
            //doc.Show(MainDockPanel);
            //toolIncremental.Searcher.Scintilla = doc.Scintilla;

            //var d = new Dashboard();
            //d.MdiParent = this;
            //d.Show();
        }

        private void FileMenuItem_Click(object sender, EventArgs e)
        {
            MainDockPanel.Hide();
            RibbonBar.Hide();
            IFileMenuComponent menuItem = ServiceLocator.Instance.Locate<IComponentManager>().Find<IFileMenuComponent>();
            if (base.Controls.Has<IFileMenuComponent>())
            { base.Controls.Remove(base.Controls.Find<IFileMenuComponent>()); }

            Control control = (Control)menuItem;
            Controls.Add(control);
            control.Dock = DockStyle.Fill;
            menuItem.Adjust(Visibility.Show);
        }
    }
}
